<?php

if(!defined('CMS_ADMIN')) {
	die("Illegal File Access");
}

$adm_pagetitle2 = _ADDRESSMNG;
$path_upload_img = "$path_upload/$adm_modname";
$result = $db->sql_query("SELECT address,map FROM ".$prefix."_contact_add WHERE alanguage='$currentlang'");
list($address,$map) = $db->sql_fetchrow($result);

if(isset($_POST['submit']) && $_POST['submit'] !="") {
	$address = trim(stripslashes(resString($_POST['address'])));
      if (is_uploaded_file($_FILES['userimage']['tmp_name'])) {
			$path_upload_img = "$path_upload/$adm_modname";
			$upload = new Upload("userimage", $path_upload_img, $maxsize_up);
			$images = $upload->send();
			//resizeImg($images, $path_upload_img, $prd_thumbsize);
		}
	if($db->sql_numrows($result) > 0) {
		$db->sql_query("UPDATE ".$prefix."_contact_add SET address='$address',map='$images' WHERE alanguage='$currentlang'");
	}else{
		$db->sql_query("INSERT INTO ".$prefix."_contact_add ( address, map, alanguage) VALUES ('$address','$images', '$currentlang')");
	}	
	updateadmlog($admin_ar[0], $adm_modname, _MODTITLE, ""._SAVECHANGES." Address");
	header("Location: modules.php?f=$adm_modname&do=$do&bf");
	exit();
}	

include("page_header.php");

echo "<form action=\"modules.php?f=$adm_modname&do=$do\" method=\"POST\" enctype=\"multipart/form-data\"><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" class=\"tableborder\">\n";
echo "<tr><td class=\"header\">"._ADDRESSMNG."</td></tr>";
echo "<tr>\n";
echo "<td>";
editor("address",$address);
echo "</td>\n";
echo "</tr>\n";
echo "<tr><td class=\"header\">"._CONTACT_MAP."</td></tr>";
if(!empty($map))
{
	echo "<tr>\n";
		echo "<td>";
		   echo "<img src=\"../$path_upload_img/$map\" width=\"150px\" height=\"100px\"/>";
		echo "</td>\n";
	echo "</tr>\n";
}
echo "<tr>\n";
echo "<td>";
   echo "<input type=\"file\" name=\"userimage\" size=\"50\">";
echo "</td>\n";
echo "</tr>\n";
echo "<tr><td align=\"center\"><input type=\"submit\" name=\"submit\" value=\""._SAVECHANGES."\" class=\"button2\"></td></tr>";
echo "</table></form>";
include_once("page_footer.php");

?>